﻿namespace zUnitTesting.TestTools
{
    using System;
    using System.IO;
    using System.Reflection;
    using System.Web;

    public static class FileLoader
    {
        public static string RetrieveTestFileContent(string testFileName, string relativePath)
        {
            string testFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase), relativePath, testFileName);
            string fileContent = null;

            using(StreamReader reader = new StreamReader(HttpUtility.UrlDecode(new Uri(testFilePath).AbsolutePath)))
            {
                fileContent = reader.ReadToEnd();
            }

            return fileContent;
        }
    }
}
